<?php

namespace Kunfeng\Dify\Model\Datasets;

/**
 * 预处理规则
 */
class PreProcessingRule
{
    private $id;
    private $enabled;

    public function __construct(array $data = [])
    {
        $this->id = $data['id'] ?? '';
        $this->enabled = $data['enabled'] ?? false;
    }

    /**
     * 从数组创建
     */
    public static function fromArray(array $data): self
    {
        return new self($data);
    }

    /**
     * 创建规则
     */
    public static function create(string $id, bool $enabled = true): self
    {
        return new self(['id' => $id, 'enabled' => $enabled]);
    }

    // Getters
    public function getId(): string
    {
        return $this->id;
    }

    public function isEnabled(): bool
    {
        return $this->enabled;
    }

    /**
     * 转换为数组
     */
    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'enabled' => $this->enabled,
        ];
    }
}
